<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link href="/lib/layui/css/layui.css" rel="stylesheet"/>
    <link href="/css/common.css" rel="stylesheet"/>
    <link rel="stylesheet" href="/lib/dtree/dtree.css">
    <link rel="stylesheet" href="/lib/dtree/font/dtreefont.css">
    <title>编辑用户信息</title>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row layui-col-space10">
        <div class="layui-card">
            <div class="layui-card-body">
                <form class="layui-form">
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="layui-color-red">*</span>&nbsp;姓名：</label>
                        <div class="layui-input-block">
                            <input class="layui-input" type="text" name="name" lay-verify="required" placeholder="请输入姓名" autocomplete="off" maxlength="100">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">头像：</label>
                        <div class="layui-input-block">
                            <input class="layui-input" type="hidden" name="picturePath">
                            <div class="layui-upload-list" id="pictureId"></div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="layui-color-red">*</span>&nbsp;性别：</label>
                        <div class="layui-input-block">
                            <select id="sexType" name="sexType" lay-verify="required" title=""></select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="layui-color-red">*</span>&nbsp;联系方式：</label>
                        <div class="layui-input-block">
                            <input class="layui-input" type="text" name="mobile" lay-verify="required|phone" placeholder="请输入联系方式" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="layui-color-red">*</span>&nbsp;用户名：</label>
                        <div class="layui-input-block">
                            <input class="layui-input" type="text" name="userName" lay-verify="required" placeholder="请输入用户名" autocomplete="off"
                                   maxlength="100">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="layui-color-red">*</span>&nbsp;状态：</label>
                        <div class="layui-input-block">
                            <select id="validState" name="validState" lay-verify="required" title=""></select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">用户角色：</label>
                            <div class="layui-input-block">
                                <div style="height: 300px; border: 1px solid #e6e6e6;overflow: auto;">
                                    <ul id="dTreeList1" class="dtree" data-id="0"></ul>
                                </div>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">组织岗位：</label>
                            <div class="layui-input-block">
                                <div style="height: 300px; border: 1px solid #e6e6e6;overflow: auto;">
                                    <ul id="dTreeList2" class="dtree" data-id="0"></ul>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <input type="hidden" name="id">
                            <input type="hidden" name="roleId">
                            <input type="hidden" name="orgId">
                            <button class="layui-btn" lay-filter="submitBtn" lay-submit data-url="/system/user/saveOrUpdate.do">提交</button>
                            <button class="layui-btn layui-hide" type="button" id="submit">提交</button>
                            <button class="layui-btn layui-btn-primary" type="button" id="cancel">取消</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script src="/lib/layui/layui.all.js" charset="utf-8"></script>
<script src="/script/common.js" charset="utf-8"></script>
<script>
    var id = getRequestParams('id');

    layui.use(['baseUtil', 'fileUtil'], function () {
        var $ = layui.jquery,
            baseUtil = layui.baseUtil,
            fileUtil = layui.fileUtil;

        baseUtil.initDict('validState,sexType', function (dictContent) {
            if (isBlank(id)) {
                baseUtil.initSelect(dictContent, 'validState', '', '1');
                baseUtil.initSelect(dictContent, 'sexType', '2');
                fileUtil.uploadImage('pictureId', '', function (file) {
                    $('input[name=picturePath]').val(file.filePath);
                });
            } else {
                var url = '/system/user/findVoOne.do';
                var params = { id: id };
                var cols = [
                    { type: 'input', name: 'id' },
                    { type: 'input', name: 'name' },
                    { type: 'input', name: 'picturePath' },
                    { type: 'select', name: 'sexType', dictContent: dictContent },
                    { type: 'input', name: 'mobile' },
                    { type: 'input', name: 'userName' },
                    { type: 'select', name: 'validState', dictContent: dictContent }
                ];
                baseUtil.initFormData(url, params, cols, function (data) {
                    fileUtil.uploadImage('pictureId', data.pictureId, function (file) {
                        $('input[name=picturePath]').val(file.filePath);
                    });
                });
            }
            baseUtil.initDTree('#dTreeList1', '/system/userrole/getTreeList.do?userId=' + id, true, 'roleId');
            baseUtil.initDTree('#dTreeList2', '/system/userorg/getTreeList.do?userId=' + id, true, 'orgId', 'self');
        });
    });
</script>
</body>
</html>
